<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="x-theme-draft">

  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/submenu.jsp"%>

<div class="container-fluid x-container has-x-sidemenu">

  <ol class="x-breadcrumb breadcrumb">
    <li class="active">权限管理&nbsp;-&nbsp;用户管理</li>
  </ol>

  <div class="x-content-layout has-operation">

    <div class="x-operation-bar no-margin no-bottom-border clearfix">
      <div class="x-operation-group pull-right">
          <a href="${ctx.host}/principals/create" data-target="#create" data-toggle="modal" class="btn x-btn x-btn-blue"> <i class="glyphicon glyphicon-plus"></i>&nbsp;&nbsp;新增用户
          </a>
        <a href="${ctx.host}/principals/search" data-target="#search" data-toggle="modal" class="btn x-btn x-btn-blue"> <i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;筛选
        </a>
      </div>
    </div>

    <table class="table table-hover x-table">
      <thead>
        <tr>
          <th>序号</th>
          <th>姓名</th>
          <th>电话</th>
          <th>角色</th>
          <th>状态</th>
          <th class="text-center">操作</th>
        </tr>
      </thead>
      <tbody>
      <c:forEach var="principal" items="${principals}" varStatus="status">
      <tr>
        <td>${status.index+1}</td>
        <td>${principal.name}</td>
        <td>${principal.mobile}</td>
        <td>${secure.roles[principal.authority].description}</td>
        <c:if test="${!principal.disabled}">
        <td>正常</td>
        </c:if>
        <c:if test="${principal.disabled}">
        <td>冻结</td>
        </c:if>
        <td class="text-center"><a href="${ctx.host}/principals/${principal.id}/edit " data-target="#edit" data-toggle="modal">编辑</a>&nbsp;&nbsp; 
          <c:if test="${!principal.disabled}">
            <a href="${ctx.host}/principals/${principal.id}/freeze" data-target="#freeze" data-toggle="modal">冻结</a>
          </c:if> 
          <c:if test="${principal.disabled}">
            <a href="${ctx.host}/principals/${principal.id}/unfreeze" data-target="#activate" data-toggle="modal">激活</a>
          </c:if> &nbsp;&nbsp; 
            <a href="${ctx.host}/principals/${principal.id}/reset-password" data-target="#reset-password" data-toggle="modal">重置密码</a>&nbsp;&nbsp;
        </td>
      </tr>
      </c:forEach>
      </tbody>
      <tfoot>
      <tr>
          <td colspan="6" class="no-vertical-padding">
            <div class="pull-left">
              <jsp:include page="/WEB-INF/include/page.jsp">
              <jsp:param name="url" value="${ctx.host}/principals" />
              <jsp:param name="queryString" value="${queryString}" />
              </jsp:include>
            </div>
          </td>
      </tr>
      </tfoot>
   </table>

  </div>
</div>
     
<%@ include file="/WEB-INF/include/footer.jsp"%>
<%@ include file="/WEB-INF/include/script.jsp"%>
<d:resource root="${ctx.resource}/build" type="script" src="js/page/authority/principal-list.js" />
<script type="text/javascript">
        require(['page/authority/principal-list'], function(page) {
            page.init();
        })
    </script>
</body>
</html>